Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

Conversation

@bjoernQ
Copy link
Contributor

@bjoernQ bjoernQ commented Feb 23, 2023

Closes #31
Closes #32

Additionally, this fixes the broken no-op feature

@MabezDev
Copy link
Member

I like the line ending / no-op changes, but I'm not so sure about the fix for #38. Currently, if you start the chip unconnected and connect via USB, it still won't print anything.

@bjoernQ
Copy link
Contributor Author

bjoernQ commented Feb 23, 2023

I like the line ending / no-op changes, but I'm not so sure about the fix for #38. Currently, if you start the chip unconnected and connect via USB, it still won't print anything.

I am also not super happy with this solution because of the case you mentioned. The only alternative I can think of is to have the timeout as low as possible and always trying to send data even if we will run into the timeout every time

@MabezDev
Copy link
Member

I think what we can do is timeout initially, then on the next run check the USB_SERIAL_JTAG_SERIAL_OUT_EP_DATA_AVAIL bit, if this is set, it means data hasn't been sent to the host so you can bail early - not sure how it behaves when the device isn't connected though. Mind giving that a try?

@bjoernQ
Copy link
Contributor Author

bjoernQ commented Feb 23, 2023

I think what we can do is timeout initially, then on the next run check the USB_SERIAL_JTAG_SERIAL_OUT_EP_DATA_AVAIL bit, if this is set, it means data hasn't been sent to the host so you can bail early - not sure how it behaves when the device isn't connected though. Mind giving that a try?

Good idea! Will test that 👍

@MabezDev
Copy link
Member

I think what we can do is timeout initially, then on the next run check the USB_SERIAL_JTAG_SERIAL_OUT_EP_DATA_AVAIL bit, if this is set, it means data hasn't been sent to the host so you can bail early - not sure how it behaves when the device isn't connected though. Mind giving that a try?

Good idea! Will test that +1

Another possible idea would be to check the USB address registers, but I don't know if they get cleared on disconnect - could be another thing to look into :)

@bjoernQ
Copy link
Contributor Author

bjoernQ commented Feb 23, 2023

I think I now have a reliable working approach

From the TRM

One thing to note is that there may be situations where the host is either not attached or the CDC-ACM virtual
port is not opened. In this case, the packets that are flushed to the host will never be picked up and the transmit
buffer will never be empty. It is important to detect this and time out, as this is the only way to reliably detect that
the port on the host side is closed.

So I guess this is the best option we have and it seems to work fine for me

Copy link
Member

@MabezDev MabezDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for taking care of this!

@bjoernQ bjoernQ merged commit 42b3af0 into main Feb 23, 2023
@bjoernQ bjoernQ deleted the fix/no-blocking-on-unconnected-serial-jtag branch February 23, 2023 16:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

jtag_serial blocks when USB is not connected Have a feature to choose \r\n or \n for new-lines

3 participants